import { BasicColumn, FormSchema } from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '书的 ID',
    align: 'center',
    dataIndex: 'id',
  },
  {
    title: '书名',
    align: 'center',
    dataIndex: 'title',
  },
  {
    title: '作者',
    align: 'center',
    dataIndex: 'author',
  },
  {
    title: '出版社',
    align: 'center',
    dataIndex: 'publisher',
  },
  {
    title: '出版日期',
    align: 'center',
    dataIndex: 'publicationDate',
    customRender: ({ text }) => {
      return !text ? '' : text.length > 10 ? text.substr(0, 10) : text;
    },
  },
  {
    title: '书的类别',
    align: 'center',
    dataIndex: 'category',
  },
  {
    title: '价格',
    align: 'center',
    dataIndex: 'price',
  },
  {
    title: '库存数量',
    align: 'center',
    dataIndex: 'stockQuantity',
  },
  {
    title: '封面图像的路径或链接',
    align: 'center',
    dataIndex: 'coverImage',
  },
  {
    title: '书的描述',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '书的评分',
    align: 'center',
    dataIndex: 'rating',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '书名',
    field: 'title',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入书名!' }];
    },
  },
  {
    label: '作者',
    field: 'author',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入作者!' }];
    },
  },
  {
    label: '出版社',
    field: 'publisher',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入出版社!' }];
    },
  },
  {
    label: '出版日期',
    field: 'publicationDate',
    component: 'DatePicker',
    dynamicRules: () => {
      return [{ required: true, message: '请输入出版日期!' }];
    },
  },
  {
    label: '书的类别',
    field: 'category',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入书的类别!' }];
    },
  },
  {
    label: '价格',
    field: 'price',
    component: 'InputNumber',
    dynamicRules: () => {
      return [{ required: true, message: '请输入价格!' }];
    },
  },
  {
    label: '库存数量',
    field: 'stockQuantity',
    component: 'InputNumber',
    dynamicRules: () => {
      return [{ required: true, message: '请输入库存数量!' }];
    },
  },
  {
    label: '封面图像的路径或链接',
    field: 'coverImage',
    component: 'Input',
  },
  {
    label: '书的描述',
    field: 'description',
    component: 'InputTextArea',
  },
  {
    label: '书的评分',
    field: 'rating',
    component: 'InputNumber',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  id: { title: '书的 ID', order: 0, view: 'number', type: 'number' },
  title: { title: '书名', order: 1, view: 'text', type: 'string' },
  author: { title: '作者', order: 2, view: 'text', type: 'string' },
  publisher: { title: '出版社', order: 3, view: 'text', type: 'string' },
  publicationDate: { title: '出版日期', order: 4, view: 'date', type: 'string' },
  category: { title: '书的类别', order: 5, view: 'text', type: 'string' },
  price: { title: '价格', order: 6, view: 'number', type: 'number' },
  stockQuantity: { title: '库存数量', order: 7, view: 'number', type: 'number' },
  coverImage: { title: '封面图像的路径或链接', order: 8, view: 'text', type: 'string' },
  description: { title: '书的描述', order: 9, view: 'textarea', type: 'string' },
  rating: { title: '书的评分', order: 10, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
